<?php
/**
 * Application-wide controller file.
 *
 * Infectamic: browser game (http://infectamic.goldzoneweb.info)
 * Copyright 2011, Loic Chardonnet
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 */

App::import('Controller', 'Controller');

/**
 * Parent class for controllers.
 */
class AppController extends Controller {
    public $uses = array('Character');
    public $helpers = array(
        'Session',
        'Html',
        'Form',
        'Js',
    );

    /**
     * Called before the controller action.
     */
    public function beforeFilter() {
        $this->Character->removeDeads();

        $generatedCharacters = $this->Character->countGeneratedForLastDay();
        if ($generatedCharacters <= LIMIT_OF_GENERATED_CHARACTERS) {
            $this->Character->generateRandomly();
        }
    }
}
